<template>
  <div class="basetable">
    <el-table
      :data="
        tableData
      "
      :show-header="true"
      
      style="width: 100%"
    >
      <el-table-column prop="create_time" label="日期" width="180">
      </el-table-column>
      <el-table-column prop="username" label="名称" width="180">
      </el-table-column>
      <el-table-column prop="note" label="内容"> </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[15, 35, 50, 100]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="content.counts"
    >
    </el-pagination>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData: [],
      content: "",
      currentPage: 1, //初始页
      pagesize: 15, //    每页的数据
    };
  },
  created() {
    this.logs();
  },
  watch: {
    tableData(val) {
      // 实时监听数据变化
      console.log(val);
      this.tableData = val;
    },
  },
  methods: {
    changePageSize(value) {
      console.log(value);
    },
    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function (size) {
      console.log(33);
      this.pagesize = size;
    },
    //点击切换页数
    async handleCurrentChange(currentPage) {
      this.currentPage = currentPage;
      console.log(currentPage);
      let Logs = (
        await this.$api.home.Logs({
          page: currentPage,
        })
      ).data;
      this.tableData = Logs.data;
      console.log(Logs.data);
      this.content = Logs;
      console.log("logs", Logs.counts);
      console.log(this.content);
      console.log(this.tableData);
    },
    //首次数据
    async logs() {
      let Logs = (
        await this.$api.home.Logs({
          page: 1,
        })
      ).data;
      this.tableData = Logs.data;
      this.content = Logs;
      console.log("logs", Logs.counts);
      console.log(this.content);
      console.log(this.tableData);
    },
  },
};
</script>